package com.sanpu.kxe.business.card.provider;

import android.content.Context;
import android.content.Intent;

import com.sanpu.kxe.business.card.bean.BankInfoInput;
import com.sanpu.kxe.business.card.bean.BankInfoOutput;
import com.sanpu.kxe.business.card.bean.DefBankOcrOutput;
import com.sanpu.kxe.business.card.contract.CardConfig;
import com.sanpu.kxe.business.card.view.AddBankResultActivity;
import com.sanpu.kxe.business.card.view.AddBankSecondActivity;
import com.sanpu.kxe.business.card.view.AddBankSetupActivity;
import com.sanpu.kxe.business.card.view.AddCreditNewActivity;
import com.sanpu.kxe.business.card.view.BankCardDetailsActivity;
import com.sanpu.kxe.business.card.view.NewUpdateDefBankActivity;
import com.sanpu.kxe.business.card.view.OldUpdateDefBankActivity;
import com.sanpu.kxe.business.card.view.UpdateBankSecondActivity;
import com.sanpu.kxe.business.card.view.UpdateBankTelActivity;
import com.sanpu.kxe.business.card.view.VerificationActivity;
import com.sanpu.kxe.utils.IntentTool;

/**
 * Description：card模块内部跳转类
 * Created by 薛勇军 on 2018/7/24.
 */

public class CardOpenProvider {

    private static CardOpenProvider instance;

    public static CardOpenProvider getInstance() {
        if (instance == null) {
            synchronized (CardOpenProvider.class) {
                if (instance == null) {
                    instance = new CardOpenProvider();
                }
            }
        }
        return instance;
    }

    /**
     * 添加信用卡
     */
    public void openAddCreditNewActivity(Context context) {
        IntentTool.startActivity(context, AddCreditNewActivity.class);
    }

    /**
     * 添加银行卡第一步
     * 输入银行卡号、获取卡信息
     */
    public void openAddBankSetupActivity(Context context) {
        IntentTool.startActivity(context, AddBankSetupActivity.class);
    }

    /**
     * 添加银行卡第二步
     * 判断卡类型、输入手机号
     */
    public void openAddBankSecondActivity(Context context, BankInfoInput infoInput, String logoPath) {
        Intent builder = new Intent(context, AddBankSecondActivity.class);
        builder.putExtra(CardConfig.INTENT_BANKINFO, infoInput);
        builder.putExtra(CardConfig.INTENT_LOGOPATH, logoPath);
        IntentTool.startActivity(context, builder);
    }

    /**
     * 添加银行卡第三步
     * 校验验证码
     */
    public void openVerificationActivity(Context context, BankInfoInput infoInput) {
        Intent builder = new Intent(context, VerificationActivity.class);
        builder.putExtra(CardConfig.INTENT_BANKINFO, infoInput);
        IntentTool.startActivity(context, builder);
    }

    /**
     * 银行卡详情
     * @param context    上下文
     * @param infoOutput 银行卡信息
     */
    public void openBankCardDetailsActivity(Context context, BankInfoOutput infoOutput, String chkSts) {
        Intent intent = new Intent(context, BankCardDetailsActivity.class);
        intent.putExtra(CardConfig.INTENT_BANKINFO_OUTPUT, infoOutput);
        intent.putExtra(CardConfig.INTENT_CHKSTS, chkSts);
        IntentTool.startActivity(context, intent);
    }

    /**
     * 修改默认结算卡
     */
    public void openUpdateDefBankActivity(Context context, String mChkSts) {
        IntentTool.startActivity(context, NewUpdateDefBankActivity.class);
    }

    /**
     * 修改默认结算卡第二步
     */
    public void openUpdateBankSecondActivity(Context context, DefBankOcrOutput ocrOutput) {
        Intent intent = new Intent(context, UpdateBankSecondActivity.class);
        intent.putExtra(CardConfig.INTENT_DEFBANKOCR_OUTPUT, ocrOutput);
        IntentTool.startActivity(context, intent);
    }

    /**
     * 修改默认结算卡
     */
    public void openOldUpdateDefBankActivity(Context context, boolean isFinish) {
        IntentTool.startActivity(context, new Intent(context, OldUpdateDefBankActivity.class), isFinish);
    }

    /**
     * 修改银行卡预留手机号
     */
    public void openUpdateBankTelActivity(Context context, BankInfoOutput infoOutput, int requestCode) {
        Intent intent = new Intent(context, UpdateBankTelActivity.class);
        intent.putExtra(CardConfig.INTENT_BANKINFO_OUTPUT, infoOutput);
        IntentTool.startActivityForResult(context, intent, requestCode);
    }

    /**
     * 绑卡结果页
     */
    public void openAddBankResultActivity(Context context) {
        IntentTool.startActivity(context, new Intent(context, AddBankResultActivity.class));
    }
}
